<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>分组名称修改</title>
<!--公共样式开始-->
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/reset.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/common.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Plugins/FontAwesome/css/font-awesome.min.css">
<!--公共样式结束-->
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/module_form.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/page_memberAdd.css">
<script src="{$NOW_THEME_URL}/Assets/Js/jquery.min.js"></script>
<script src="{$NOW_THEME_URL}/Assets/Js/jquery.timer.js"></script>
<script src="{$NOW_THEME_URL}/Assets/Js/common.js"></script>
<!--数据列表插件开始-->
<link href="{$NOW_THEME_URL}/Assets/Plugins/ContextMenu/src/jquery.contextMenu.css" rel="stylesheet" type="text/css" />
<link href="{$NOW_THEME_URL}/Assets/Plugins/Etgrid/Css/etgrid.css" rel="stylesheet" type="text/css">
<script src="{$NOW_THEME_URL}/Assets/Plugins/ContextMenu/src/jquery.ui.position.js"></script>
<script src="{$NOW_THEME_URL}/Assets/Plugins/ContextMenu/src/jquery.contextMenu.js"></script>
<script src="{$NOW_THEME_URL}/Assets/Plugins/Etgrid/Js/etgrid.js"></script>
<!--数据列表插件结束-->
</head>

<body>
	<div class="page_header">
 	<div class="table_tool">
		<ul class="clearfix">	
			<li class="plremove btn"><i class="icon-remove"></i> 批量删除</li>		
			<li class="line"></li>
			<li class="openwin btn" etitle="添加组员" eheight="500px" ewidth="700px" ehref="{:U('Group/addMember')}&id={$Think.get.id}" id="addMember"><i class="icon-plus"></i> 添加组员</li>
			<li class="line"></li>
			<li class="memberGroup btn">
				<i class="icon-group"></i><a id="ydz">移动至</a>
				<ul class="submenu">
					<volist name="details" id="vo">
						<li rel="{$vo.id}" title="{$vo.title}"><i class="icon-caret-right"></i>{$vo.title}</li>
					</volist>
				</ul>
			</li>
			
			
		</ul>
	</div>
	
		<div class="tabbar">
			<ul class="clearfix" tabname="tab1">	
				<li class="tabhover" show="tab1_0">修改分组名称</li>
				<li show="tab1_1">组内成员</li>
			</ul>
		</div>
	</div>
	<div class="page_wraper" style="margin-top:10px;">
		<div id="tab1_0" fortab="tab1">
			<form action="" method="post" id="memberAdd_form">
			<input type="hidden" id="vipcard_id" value="{$detail.id}" />
				<table cellpadding="0" cellspacing="0" class="module_form">
					<tr>
						<td class="ele_title"><label for="cardnum">分组名称：<em>*</em></label></td>
						<td class="ele_content">
							<input value="{$detail.title}" type="text" id="title" class="form_ele_text width_200">
						</td>
					</tr>
				</table>
			</form>
			<div class="page_footer pdtd10">
				<input type="button" name="submit" value="确认修改"  class="form_ele_submit"/>
				<input type="reset" name="reset" value="重置表单"  class="form_ele_reset"/>
			</div>
		</div>
		<div id="tab1_1" fortab="tab1" class="clearfix" style="display:none;margin-top: -20px;">
			<div class="table_box">
			</div>
		</div>
	</div>
	
</body>
<script type="text/javascript">
var listConfig = {
		blockBox : '.table_box',
		blockBoxHeight : 'window',
		jsonUrl : '__URL__/edit/groupid/{$Think.get.id}',
		where : '',
		widthType : 'tdw', //thw-标题标准宽度、tdw-数据单元标准宽度、auto-随数据单元宽度
		pageNum : 10,
		nowPage : 1, 
		orderName : "addtime",
		orderDirection : "desc", 
		dataContextMenuOpen: true, //是否开启数据行右键菜单
		dataContextMenu: function(){
			$.contextMenu({
				selector: '.et_tbody tr',
				items: {
					"detail": {
						name: "查看", 
						icon: "remove",
						callback: function(key, options) {
							var href = "{:U('Custom/detail')}&id="+$(this).attr('rowid');
							var width = '900px';
							var height = '500px';
							var title = '会员详情';
							openDialog('customDetail',href,width,height,title);
						}
					},
					"edit": {
						name: "修改", 
						icon: "edit",
						callback: function(key, options) {
							var href = "{:U('Custom/edit')}&id="+$(this).attr('rowid');
							var width = '900px';
							var height = '400px';
							var title = '修改会员';
							openDialog('customEdit',href,width,height,title);
						}
					},
					"delete": {
						name: "删除", 
						icon: "remove",
						callback: function(key, options) {
							//var title =  $(this).children('td[fieldname="title"]').html();
							
							var customid = $(this).attr('rowid');
							var groupid  = '{$Think.get.id}';
							$.get("{:U('Group/memberGroupDel')}",{customid:customid,groupid:groupid},function(data){
								$('.et_tfoot .page_refresh').click(); //刷新加载
							})
						}
					}
				}
			});
		},
		colModel : [
				{
					display : 'checkbox',
					name : 'id',
					sortable : false,
					myclass : 'center',
					edit : false,
					width:'20px'
				},
				{
					display : '姓名',
					name : 'realname',
					sortable : true,
					myclass : 'center',
					edit : false,
					width:'100px'
				},
				{
					display : '手机号码',
					name : 'mobile',
					sortable : true,
					myclass : 'center',
					edit : false,
					width:'150px'
				},
				{
					display : '电邮',
					name : 'email',
					sortable : true,
					edit : false,
					width:'250px'
				},
				{
					display : '性别',
					name : 'sex',
					sortable : true,
					myclass : 'center',
					edit : false,
					width:'80px'
				}
		]
	};

	//实例化列表
	var tableList = $('.table_box').EtGrid(listConfig);
	//弹出窗口全局变量
	var api = frameElement.api, W = api.opener;

	$(function(){
		//滑动门
		$('.tabbar li').click(function(){
			var tabname = $('.tabbar>ul').attr('tabname');
			$('.tabbar li').removeClass('tabhover');
			$(this).addClass('tabhover');
			
			$('div[fortab="'+tabname+'"]').hide();
			$('#'+$(this).attr('show')).show();
		});
		//表单操作
		//重置
		$('.form_ele_reset').on('click',function(){
			frameApi.close(); //关闭当前窗口
		});
		
		$(".form_ele_submit").on("click",function(){
			var id      = tableList.getChecked();
			var groupid = '{$Think.get.id}';
			$.get("{:U('Group/addMem')}",{id:id,groupid:groupid},function(data){

				windowApi.lhgdialog.tips('添加成功！',1,etIcon.success,function(){
					frameApi.close(); //关闭当前窗口
					var obj = windowApi.lhgdialog.list['groupIndex'];
					obj.reload(obj);
					
				});
			});
		});
		
 	    $(".plremove").on("click",function(){
 			var groupid = '{$Think.get.id}';
 			var id      = tableList.getChecked();
 			$.get("{:U('Group/memberGroupDel')}",{customid: id,groupid: groupid},
	 			function(d){
	 				windowApi.lhgdialog.tips('数据修改成功！',1,etIcon.success,function(){
	 				$('.et_tfoot .page_refresh').click(); //刷新加载
	 			}); 
			}); 
		}); 
		
		//调整会员分组
		$(".memberGroup .submenu>li").on('click',function(){
			var groupid      = $(this).attr("rel");
			var id  = tableList.getChecked();
			if(id==""){
				alert("请选择一个会员！~~");
				return false;
			}
	 		$.get("{:U('Group/move')}",{id: id,groupid: groupid},
	 			function(d){
	 				windowApi.lhgdialog.tips('数据修改成功！',1,etIcon.success,function(){
	 				$('.et_tfoot .page_refresh').click(); //刷新加载
	 			}); 
			}); 
	 		
		}); 
		
		//提交
		$('.form_ele_submit').on('click',function(){
			//通过POST直接提交表单
			//$('#memberAdd_form').get(0).submit();
			//etcommon.maskShow();
			
			var tipsObj = windowApi.lhgdialog.tips('正在提交数据...',10,etIcon.loading);
			
			//通过Ajax提交表单
			var postData = {};
			postData.title   = $('#title').val(); //获取会员等级
			postData.id      = $('#vipcard_id').val(); //获取会员等级
			
			//console.log(postData);
			
			$.post("{:U('Group/edits')}", postData ,
				function(data){
					tipsObj.close();
					windowApi.lhgdialog.tips('数据修改成功！',1,etIcon.success,function(){
						//Ajax通讯成功后处理
						var width  = '900px';
						var height = '500px';
						var title  = '分组修改';
						openDialog('groupIndex',width,height,title);
						
						frameApi.close(); //关闭当前窗口
						
						//windowApi.lhgdialog.list['d001'].close(); //指定关闭Id的窗口
					});
				}, "json"
			);
		});
	});
</script>
</html>
